package com.finstone.data.spider.eshop.service.impl;

import com.finstone.data.spider.eshop.pipeline.EShopPagePipline;
import com.finstone.data.spider.eshop.pipeline.weibo.WeiBoPagePipline;
import com.finstone.data.spider.eshop.processor.EShopPageProcessor;
import com.finstone.data.spider.eshop.processor.weibo.WeiBoPageProcessor;
import com.finstone.data.spider.eshop.service.AbstractSpiderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import us.codecraft.webmagic.Request;
import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.pipeline.JsonFilePipeline;

import javax.annotation.PostConstruct;

/**
 * Created by Sean on 2016/3/22.
 */
@Component
public class WeiBoPageService extends AbstractSpiderService<String> {
    @Autowired
    private WeiBoPageProcessor weiBoPageProcessor;

    @Autowired
    private WeiBoPagePipline weiBoPagePipline;

    @Override
    @PostConstruct
    public void init() {
        spider = Spider.create(weiBoPageProcessor).addPipeline(weiBoPagePipline).thread(5);
    }

    @Override
    protected void doPutTask(String url) {
        Request request = new Request(url);
//        init();
        spider.addRequest(request);
//		spider.addUrl(url);
    }
}
